package com.dmxh.controller;

import com.dmxh.pojo.TbUser;
import com.dmxh.result.Result;
import com.dmxh.service.UserService;
import com.dmxh.vo.UserVo;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/sendMessage")
    public Result sendMessage(@RequestParam String phone) {
        return userService.sendMessage(phone);
    }

    @PostMapping("/register")
    public Result register(@RequestBody UserVo userVo) {
        return userService.register(userVo);
    }

    @PostMapping("/queryByName")
    public TbUser queryByName(@RequestBody String username) {
        return userService.queryByName(username);
    }

    @GetMapping("/queryUserById/{id}")
    public TbUser queryUserById(@PathVariable("id")long id) {
        return userService.queryById(id);
    }
}
